package com.liuweiheng.cloudproviderpayment8002.common.controller;


import com.liuweiheng.base.entity.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * 对外提供Feign测试接口
 *
 * @author lwh
 */
@RestController
@RequestMapping("/payment/feign")
public class FeiginController {

    /**
     * 提供测试Feign调用接口
     */
    @GetMapping("/test")
    public R testFeign() {
        return R.ok("Use Feign Service Success");
    }

    /**
     * 提供测试Feign调用超时接口
     * 睡眠三秒，Feign默认调用超时为1秒
     */
    @GetMapping("/timeout")
    public R testFeignTimeout() {
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return R.ok();
    }

}
